<%-- 
    Document   : venditeEffettuate
    Created on : 8-gen-2013, 20.57.58
    Author     : Luciano
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.List"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Asta"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.User"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Product"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.DBManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%!
    private DBManager db;
    
    @Override
    public void init() throws UnavailableException{
            db=(DBManager)super.getServletContext().getAttribute("db_manager");
            
    }
%>        

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Vendite effettuate</title>
    </head>
    <body>
        <%
         List<Asta> asteScadute=db.getAsteAggiudigate();
        %>   
        <div class="content">
            <h2>ASTE SCADUTE:</h2>
            <br/>
            <%
              if(asteScadute.isEmpty()){
                %>
                <h3>Non ci sono aste aggiudicate</h3>
                <%     
              }else{
                int i=1;
                for(Asta as:asteScadute){
                   request.setAttribute("asta", as);
                   User seller = as.getSeller();
                   Product product = as.getProduct();
                   double commissioni= ((as.getLast_offer_price()*1.25)/100);
                  %>   
                  <jsp:include page="../user/astaDetails.jsp" flush="true" />
                  <h4>Commission: </h4><p><%=commissioni %></p>
                  <form name="scaricaExcel" method="post" action="<%=response.encodeURL(request.getContextPath())%>/services/scaricaExcel" >
                      <input type="hidden" name="id" value="<%=as.getId() %>" />
               
                      <h3>Scarica excel:</h3>
                      <input type="submit" name="scaricaExcel" value="scaricaExcel"/>
                  </form>
                
            <%
                 i++;
              }
            }
            %>                      
        </div>
    </body>
</html>
